#include "printsetting.h"
#include "tools.h"

PrintSetting::PrintSetting(QObject *parent) : QObject(parent)
{

}

PrintSetting::PrintSetting(QString settingKey){
    this->settingKey = settingKey;
    this->settingPrefix = QString("printSetting/%1").arg(settingKey);
}

void PrintSetting::setSettingKey(QString settingKey){
    this->settingKey = settingKey;
    this->settingPrefix = QString("printSetting/%1").arg(settingKey);
}

void PrintSetting::save(){
    Tools::saveValue(settingPrefix, "title", title);
    Tools::saveValue(settingPrefix, "paperWidth", paperWidth);
    Tools::saveValue(settingPrefix, "paperHeight", paperHeight);
    Tools::saveValue(settingPrefix, "headerItem1", headerItem1);
    Tools::saveValue(settingPrefix, "headerItem2", headerItem2);
    Tools::saveValue(settingPrefix, "headerItem3", headerItem3);
    Tools::saveValue(settingPrefix, "headerItem4", headerItem4);
    Tools::saveValue(settingPrefix, "headerItem5", headerItem5);
    Tools::saveValue(settingPrefix, "headerItem6", headerItem6);
    Tools::saveValue(settingPrefix, "headerItem7", headerItem7);
    Tools::saveValue(settingPrefix, "headerItem8", headerItem8);
    Tools::saveValue(settingPrefix, "headerItem9", headerItem9);
    Tools::saveValue(settingPrefix, "headerItem10", headerItem10);
    Tools::saveValue(settingPrefix, "tailItem1", tailItem1);
    Tools::saveValue(settingPrefix, "tailItem2", tailItem2);
    Tools::saveValue(settingPrefix, "tailItem3", tailItem3);
    Tools::saveValue(settingPrefix, "tailItem4", tailItem4);
    Tools::saveValue(settingPrefix, "tailItem5", tailItem5);
    Tools::saveValue(settingPrefix, "tailItem6", tailItem6);
    Tools::saveValue(settingPrefix, "tailItem7", tailItem7);
    Tools::saveValue(settingPrefix, "tailItem8", tailItem8);
    Tools::saveValue(settingPrefix, "tailItem9", tailItem9);
    Tools::saveValue(settingPrefix, "tailItem10", tailItem10);
}

void PrintSetting::load(){
    title = Tools::loadValue(settingPrefix, "title").toString();
    paperWidth = Tools::loadValue(settingPrefix, "paperWidth").toInt();
    paperHeight = Tools::loadValue(settingPrefix, "paperHeight").toInt();
    headerItem1 = Tools::loadValue(settingPrefix, "headerItem1").toString();
    headerItem2 = Tools::loadValue(settingPrefix, "headerItem2").toString();
    headerItem3 = Tools::loadValue(settingPrefix, "headerItem3").toString();
    headerItem4 = Tools::loadValue(settingPrefix, "headerItem4").toString();
    headerItem5 = Tools::loadValue(settingPrefix, "headerItem5").toString();
    headerItem6 = Tools::loadValue(settingPrefix, "headerItem6").toString();
    headerItem7 = Tools::loadValue(settingPrefix, "headerItem7").toString();
    headerItem8 = Tools::loadValue(settingPrefix, "headerItem8").toString();
    headerItem9 = Tools::loadValue(settingPrefix, "headerItem9").toString();
    headerItem10 = Tools::loadValue(settingPrefix, "headerItem10").toString();
    tailItem1 = Tools::loadValue(settingPrefix, "tailItem1").toString();
    tailItem2 = Tools::loadValue(settingPrefix, "tailItem2").toString();
    tailItem3 = Tools::loadValue(settingPrefix, "tailItem3").toString();
    tailItem4 = Tools::loadValue(settingPrefix, "tailItem4").toString();
    tailItem5 = Tools::loadValue(settingPrefix, "tailItem5").toString();
    tailItem6 = Tools::loadValue(settingPrefix, "tailItem6").toString();
    tailItem7 = Tools::loadValue(settingPrefix, "tailItem7").toString();
    tailItem8 = Tools::loadValue(settingPrefix, "tailItem8").toString();
    tailItem9 = Tools::loadValue(settingPrefix, "tailItem8").toString();
    tailItem10 = Tools::loadValue(settingPrefix, "tailItem10").toString();
}
